package oa.dao.user.impl;

import java.util.List;

import oa.dao.user.UserDAO;
import oa.entity.user.User;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDAOImpl extends HibernateDaoSupport implements UserDAO {

	@SuppressWarnings("unchecked")
	public List<User> findAllUsers() {
		String hql = "from User user order by user.id desc";
		
		return (List<User>)this.getHibernateTemplate().find(hql);
	}

	public User findUserById(Integer id) {
		return (User) this.getHibernateTemplate().get(User.class, id);
	}

	public void removeUser(User user) {
		this.getHibernateTemplate().delete(user);
	}

	public void saveUser(User user) {
		this.getHibernateTemplate().save(user);
	}

	public void updateUser(User user) {
		this.getHibernateTemplate().update(user);
	}

}
